/**
 * desc: The `batchLog` service allows for messages to be queued in memory
 *       and flushed to the console.log every 60 seconds.
 * author: Joe
 * date: 7/20/2018
 */

coreModule.factory('batchLog',
  [
    '$interval', '$log',
    function($interval, $log) {
      var messageQueue = [];

      function log() {
        if (messageQueue.length) {
          $log.log('batchLog messages:', messageQueue);
          messageQueue = [];
        }
      }

      $interval(log, 60 * 100);

      return function(message) {
        messageQueue.push(message);
      };
    },
  ]
);
